<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Login</title>
		<script type="text/javascript" language="javascript">
			window.onload = function() {
				document.getElementById("form").onsubmit = function() {
					var form = document.getElementById("form");
					var iderrormsg = document.getElementById("iderrormsg");
					//获取文本框的值
					var username = form.username.value;
					var password = form.password.value;
					//判断非空的正则(字符串中间也不能有空格)
					var regex = /^\S+$/;
					if (!regex.test(username)) {
						//firefox版本 (貌似通用)
						iderrormsg.textContent = "name?";
						/*ie版本iderrormsg.innerText = "name?";*/
						return false;
					}
					if (!regex.test(password)) {
						iderrormsg.textContent = "password?";
						return false;
					}
					return true;
				};
			};
		</script>
	</head>
	<body>
		<jsp:include page="/jspdemo/header.jsp" />
		<label id="iderrormsg">${msg}</label>
		<form id="form" action="/test/userOperateServlet?useroperate=login" method="post" >
			<table border="1" cellspacing="0" bordercolor="red">
				<tr>
					<td>用户名：</td>
					<td><input type="text" name="username" /></td>
				</tr>
				<tr>
					<td>密码：</td>
					<td><input type="password" name="password" />
					</td>
				</tr>
				<tr>
					<td><input type="reset" value="重置" /></td>
					<td colspan="2"><input type="submit" value="登录" /></td>
				</tr>
			</table>
		</form>
	</body>
</html>